27/11/20, updated 01/12/20 with masking + renorm fix PH
Data analysis for 450/440eV pump-probe, 1$\mu$m focus (I think) - should be comparable to previous analysis posted by TMO team (Taran...?), running from v4 preprocessed data.
Using VMIproc class for VMI data analysis & interactive plotting, including uncertainties.
Implemented:
To do:
Background:
# # Memory profiler - OPTIONAL for testing
# # https://timothymonteath.com/articles/monitoring_memory_usage/
# %load_ext memory_profiler
# %memit
# # Quick hack for slow internet connection!
# %autosave 36000
# Standard imports
from pathlib import Path
import sys
import numpy as np
import xarray as xr
# Import class from file
sys.path.append(r'/cds/home/p/phockett/dev/tmo-dev/tmo')
import tmoDataBase as tb
# from vmi import VMI # VMI class
from inversion import VMIproc # VMI processing class
tb.setPlotDefaults() # Set plot defaults (optional)
# Set main data path
baseDir = Path('/reg/data/ana15/tmo/tmolw0618/scratch/preproc/v5')
# Setup class object and which runs to read.
data = VMIproc(fileBase = baseDir, runList = range(81,87+1), fileSchema='_v5')
# The class has a bunch of dictionaries holding info on the data
# data.runs['files']
# Read in the files with h5py
# There is very basic checking implemented currently, just to see if 'energies' is present.
data.readFiles()
# Add a filter to an existing filterset
# Set energy filter to match previous analysis
# TODO: implement event count filter here to check for saturation
# data.setFilter({'signal':{'energies':[0.05, 0.1]}})
data.setFilter(reset=True)
data.setFilter({'signal':{'evrs':[1,1,70]}}) # For v4 data, gas == evrs[:,70] true/false
data.setFilter({'bg':{'evrs':[0,0,70]}})
data.setFilter({'energies':[0.05, 0.1]})
data.filters
Note this defaults to electron coords ('xc','yc').
data.genVMIXmulti()
# Check some metrics
print(data.data[81]['signal']['metrics'])
print(data.data[81]['bg']['metrics'])
# Check an image with Xarray plotter (Matplotlib)
data.imgStack['signal'].sel(run=81).pipe(np.log10).plot.imshow()
# Subtraction, and set as new image set
data.imgStack['sub'] = data.imgStack['signal'] - data.imgStack['bg']
data.imgStack
# View full image stack
data.showImgSet()